<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      filter 的主要作用就是格式化数据

     -->
    <div id="app">
      <p>{{ msg | aaa }}</p>
      <p>{{ bbb(msg) }}</p>
    </div>

    <script src="../lib/vue-2.js"></script>

    <script>
      new Vue({
        el: "#app",
        data() {
          return {
            msg: "hello",
          };
        },
        methods: {
          bbb(value) {
            console.log("aaa", value);
            // 需要有 return
            return value.charAt(0).toUpperCase() + value.slice(1);
          },
        },
        filters: {
          aaa(value) {
            console.log("aaa", value);
            // 需要有 return
            return value.charAt(0).toUpperCase() + value.slice(1);
          },
        },
      });
    </script>
  </body>
</html>
